import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

class HelloServer {
    public static void main(String[] args) throws Exception {
        // 9999端口绑定监听
        ServerSocket serverSocket = new ServerSocket(9999);
        System.out.println("服务器启动监听...");
        // 等待客户端连接
        Socket client = serverSocket.accept();
        System.out.println("客户端连接成功，准备输出数据");
        // 取得输出流
        PrintStream out = new PrintStream(client.getOutputStream());
        out.println("HELLO, I'M SERVER, CLIENT IP:" + client.getInetAddress());
        // 资源关闭
        out.close();
        client.close();
        serverSocket.close();
    }
}